package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.customer.CustomerLogin;
import com.ruoyi.system.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GalleryCollectionMapper;
import com.ruoyi.system.domain.GalleryCollection;
import com.ruoyi.system.service.IGalleryCollectionService;

import javax.servlet.http.HttpServletRequest;

/**
 * 免费图库收藏Service业务层处理
 *
 * @author ruoyi
 * @date 2021-05-19
 */
@Service
public class GalleryCollectionServiceImpl implements IGalleryCollectionService
{
    @Autowired
    private GalleryCollectionMapper galleryCollectionMapper;
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private TokenUtils tokenUtils;
    /**
     * 查询免费图库收藏
     *
     * @param collectionId 免费图库收藏ID
     * @return 免费图库收藏
     */
    @Override
    public GalleryCollection selectGalleryCollectionById(Long collectionId)
    {
        return galleryCollectionMapper.selectGalleryCollectionById(collectionId);
    }

    /**
     * 查询免费图库收藏列表
     *
     * @param galleryCollection 免费图库收藏
     * @return 免费图库收藏
     */
    @Override
    public List<GalleryCollection> selectGalleryCollectionList(GalleryCollection galleryCollection)
    {
        return galleryCollectionMapper.selectGalleryCollectionList(galleryCollection);
    }

    /**
     * 新增免费图库收藏
     *
     * @param galleryCollection 免费图库收藏
     * @return 结果
     */
    @Override
    public int insertGalleryCollection(GalleryCollection galleryCollection)
    {
        return galleryCollectionMapper.insertGalleryCollection(galleryCollection);
    }

    /**
     * 修改免费图库收藏
     *
     * @param galleryCollection 免费图库收藏
     * @return 结果
     */
    @Override
    public int updateGalleryCollection(GalleryCollection galleryCollection)
    {
        return galleryCollectionMapper.updateGalleryCollection(galleryCollection);
    }

    /**
     * 批量删除免费图库收藏
     *
     * @param collectionIds 需要删除的免费图库收藏ID
     * @return 结果
     */
    @Override
    public int deleteGalleryCollectionByIds(Long[] collectionIds)
    {
        return galleryCollectionMapper.deleteGalleryCollectionByIds(collectionIds);
    }

    /**
     * 删除免费图库收藏信息
     *
     * @param collectionId 免费图库收藏ID
     * @return 结果
     */
    @Override
    public int deleteGalleryCollectionById(Long collectionId)
    {
        return galleryCollectionMapper.deleteGalleryCollectionById(collectionId);
    }

    @Override
    public Long galleryByCustomerId() {
        CustomerLogin customerLogin = tokenUtils.getLoginCustomer(request);
        return galleryCollectionMapper.galleryByCustomerId(customerLogin.getCustomerId());
    }
}